<?php

namespace app\common\model;

use think\Exception;
use think\Model;


class OrderThird extends Model
{

    // 表名
    protected $name = 'order_third';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    const TYPE_PAY = 1; // 支付
    const TYPE_REFUND = 2; // 退款


    public static function paySuccess($third_order_sn){
        $data = self::where('third_order_sn', $third_order_sn)->find();
        if(empty($data)){
            throw new Exception("订单不存在");
        }
        $order = Order::where('id', $data->order_id)->find();
        if(empty($data)){
            throw new Exception("订单不存在");
        }
        Order::paySuccess($order);
        return true;
    }
}
